function search(arr, target, start, end) {
  while (start < end) {
    let mid = Math.floor(end - start)
    if (arr[mid] === target) return mid
    else if (arr[mid] < target) {
      start = mid + 1
    } else {
      end = mid - 1
    }
  }
  return -1
}
const dataArr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
console.log(search(dataArr, 10, 0, 8));